﻿using Iworld.Administrator.Model;
using Iworld.basis.Service;
using Iworld.Basis.Manager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace Iworld.Administrator.Service.Import
{
    /// <summary>
    /// 移除管理员数据集
    /// </summary>
    [DataContract]
    public class RemoveAdministratorImport : CheckAdministratorImportBase, IPackageForRemoveModel<IModelToDbContextOfAdministrator>
    {

        /// <summary>
        /// 存储指针
        /// </summary>
        [DataMember]
        public int Id { get; set; }

        public override void CheckAllowExecuteOrNot(Main.Impl.ModelToDbContext db)
        {
            base.CheckAllowExecuteOrNot(db);
            if (!Self.Group.CanEditAdministrator)
            {
                throw new Exception("你无权修改或添加管理员");
            }
            Model.Administrator admin = db.Administrators.Find(Id);
            if(admin.Account == SuperAcountInfoPackage.Account)
            {
                throw new Exception("不能删除超级管理员");
            }
        }

        public void CheckData(IModelToDbContextOfAdministrator db)
        {
            
        }

         
    }
}
